package com.zyf.service;

import cn.hutool.core.io.FileUtil;
import com.zyf.utils.FFmpegUtils;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * 处理图片合成操作类
 */
public class HandleFileService {
    /**
     * 批量将图片高清化
     */
    public void renameFile(String videoPath) throws Exception {
        List<File> files = FileUtil.loopFiles(videoPath, file -> file.isFile() && (file.getName().contains(".jpg")));
        for(File imgfile:files){
            try {
                String path=imgfile.getAbsolutePath();
                String name=path.replace("(","").replace(")","").replace(" ","");
                File newFile = new File(name);

                boolean isRenamed = imgfile.renameTo(newFile);

                if (isRenamed) {
                    System.out.println("文件名修改成功");
                } else {
                    System.out.println("文件名修改失败");
                }
            } catch (Exception e) {
                throw new RuntimeException("ffmpeg执行异常" + e.getMessage());
            }


        }
    }


















}
